package com.shengyin.ec.model.dao.alliance;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.shengyin.ec.model.dao.BaseDaoImpl;
import com.shengyin.ec.model.entity.AllianceSDInfo;

@Repository("allianceSDInfoDao")
public class AllianceSDInfoDaoImpl extends BaseDaoImpl<AllianceSDInfo> implements AllianceSDInfoDao {
	
	public AllianceSDInfo getAllianceSDInfoById(long id){
		List<AllianceSDInfo> asdiList =  super.find("from AllianceSDInfo where id='"+id+"'");
		
		return asdiList.get(0);
	}
	
	public List<AllianceSDInfo> getAllianceSDInfoListByCompanyId(long companyId){
		List<AllianceSDInfo> asdiList =  super.find("from AllianceSDInfo where msgType=1 and companyId='"+companyId+"'");
		
		return asdiList;
	}
	
	public List<AllianceSDInfo> getAllianceDemandInfoListByCompanyId(long companyId){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=2 and companyId='"+companyId+"'");
		
		return asdiList;
	}
	
	public List<AllianceSDInfo> getAllInfoListByCompanyId(long companyId){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=1 and companyId='"+companyId+"'");
		
		return asdiList;
	}
	
	@Override
	public List<AllianceSDInfo> getSupplyInfoListByTime(long companyId){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=1 and companyId='"+companyId+"' order by createDate desc");
		
		return asdiList;
	}
	
	@Override
	public List<AllianceSDInfo> getSupplyInfoListByCompany(long companyId){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=1 and companyId='"+companyId+"'");
		
		return asdiList;
	}
	
	@Override
	public List<AllianceSDInfo> getAllSupplyInfoListByTime(){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=1 order by createDate desc");
		
		return asdiList;
	}
	
	@Override
	public List<AllianceSDInfo> getSupplyInfoListByCompanyType(){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=1 order by companyId");
		
		return asdiList;
	}
	
	@Override
	public List<AllianceSDInfo> getAllSupplyInfoList(){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=1");
		
		return asdiList;
	}
	
	@Override
	public List<AllianceSDInfo> getDemandInfoListByTime(long companyId){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=2 and companyId='"+companyId+"' order by createDate desc");
		
		return asdiList;
	}
	
	@Override
	public List<AllianceSDInfo> getAllDemandInfoListByTime(){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=2 order by createDate desc");
		
		return asdiList;
	}
	
	@Override
	public List<AllianceSDInfo> getAllDemandInfoList(){
		List<AllianceSDInfo> asdiList = super.find("from AllianceSDInfo where msgType=2");
		
		return asdiList;
	}
	
	
	
}